/**************************************************************
  > File Name: 4.c
  > Author: LuoLiang
  > Mail: 1204553475@qq.com 
  > Created Time: 2022年01月11日 星期二 10时04分14秒
 **************************************************************/

#include <stdio.h>
#include <stdlib.h>

#define m 5
#define n 4

double func(int *a,int *b)
{
	int length = m + n;
	int p = 0, q = 0;
	int prev = -1, cur = -1;
	int i;

	for (i = 0; i <= length/2; i++)
	{
		prev = cur;
		if (p < n && (q >= m || a[p] < b[q]))
		{
			cur = a[p];
			p++;
		}
		else
		{
			cur = b[q];
			q++;
		}

	}
	if (length % 2 == 0)
		return (cur + prev) / 2.0;
	return cur;

}




int main(int argc,char **argv)
{
	int a[n] = {1,2,3,3};
	int b[m] = {2,4,5,7,9};
	
	printf("%f\n",func(a,b));
    exit(0);
}
